// shrub.txt
// This script is a very dummed-down version of basicnpc, used for immobile
//  plants and shrubs, similar to the ones seen in A4-6. This creature won't
//  even attack, as that part of the script has been removed.
//
// Unless you count what happens upon death as an attack. More of an explosion.
//
// One important note. The detonation only happens if a party member hits the
//  shrub. Thanks to Nikki for suggesting it, because this way you don't have
//  to freak out about other friendlies targeting the shrubs and ruining it all.
//
// Memory Cells:
//   Cell 0 - What type of shrub.
//		1 = Fiery Shrub. Explodes on death, deals fire damage.
//   Cell 1,2 - Stuff done flag. If both 0, nothing. Otherwise when this 
//     is killed, set to 1. (Example: If cell 1 is 3 and cell 2 is 5, when
//     creature is killed, sets SDF(3,5) to 1.)

begincreaturescript;

variables;

short i,target;

body;

beginstate INIT_STATE;
		set_mobility(ME,0);
	break;

beginstate DEAD_STATE;
	// Set the appropriate stuff done flag for this character being dead
	if ((get_memory_cell(1) != 0) || (get_memory_cell(2) != 0))
		set_flag(get_memory_cell(1),get_memory_cell(2),1);
	
	//Now the fun part... exploding shrubs!
	
	//First, if something other than a party member hit me, I'm a dud.
	if(who_hit_me() >= 4) {
		print_named_str(ME,"emits a blast of hot air, and withers.");
		end();
		}
	
	//Type 1: Fiery Shrub. Explodes in a cloud of flames.
	if(get_memory_cell(0) == 1) {
		print_named_str(ME,"explodes!");

		put_boom_on_char(ME,1,0);
		run_animation_sound(5); //Sound: small explosion
		
		//Now, make it look like I died
		pause(1);
		set_character_pose(ME,11);
		force_instant_terrain_redraw();
		pause(1);
		set_character_pose(ME,12);
		force_instant_terrain_redraw();
		pause(1);
		set_character_pose(ME,13);
		force_instant_terrain_redraw();
		pause(1);
		set_character_pose(ME,14);
		force_instant_terrain_redraw();
		pause(1);
		erase_char(ME);
		//What, you didn't think you'd get xp, did you?
		
		damage_nearby(55,2,1,2); //Deal 55 fire damage to ALL within 2 sq.
		}
	

	
	
	//More types of shrubs can go here.
	
break;

beginstate START_STATE; 

	//I do not attack.
	end_combat_turn();
	
break;

beginstate 3; // attacking

	//I do not attack.

break;

beginstate TALKING_STATE;

	//I do not talk.
	print_str("Talking: It doesn't respond.");

break;